﻿/* *****************************************************************************
* Creator: Rastko Šoškić - rssole@hotmail.com
* Date: 07/29/2009
* Description: OrderedImage control
*
*
* ****************************************************************************** */

using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Rastko.OrderedImageLoading.Controls
{
    [DefaultProperty("LoadingOrder")]
    [ToolboxData("<{0}:OrderedImage runat=server></{0}:OrderedImage>")]
    public class OrderedImage : Image
    {
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            var imgLoadingManager = ImageLoadingManager.GetCurrent(Page);
            imgLoadingManager.RegisterOrderedImage(this);
        }

        /// <summary>
        /// Gets or sets image loading order
        /// </summary>
        /// <remarks>Notice that if multiple instances of OrderedImageControl has
        /// same loading order you have no control in what order such images will
        /// be loaded</remarks>
        [Bindable(true)]
        [Browsable(true)]
        [Category("Behavior")]
        [Localizable(false)]
        [DefaultValue(0)]
        public int LoadingOrder { get; set; }
    }
}
